package com.ssy.lingxi.purchase.api.enums.purchase;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 采购计划- 内部操作枚举类
 *
 * @author lxc
 * @date 2022/2/28
 */
public enum PurchasePlanOperateEnum {

    TO_BE_SUBMIT(1, "待提交审核采购计划"),
    EXAMINE1(2, "审核采购计划(一级)"),
    EXAMINE2(3, "审核采购计划(二级)"),
    IMPLEMENT_PURCHASE(4, "执行采购计划");
    /**
     * 状态
     */
    private Integer state;

    /**
     * 描述
     */
    private String name;

    public static String getName(Integer state){
        PurchasePlanOperateEnum workEnum = Arrays.stream(PurchasePlanOperateEnum.values()).filter(v -> v.getState().equals(state)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(PurchasePlanOperateEnum.class, workEnum.getState());
    }

    public static String getName(String name){
        PurchasePlanOperateEnum workEnum = Arrays.stream(PurchasePlanOperateEnum.values()).filter(v -> v.getCHName().equals(name)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(PurchasePlanOperateEnum.class, workEnum.getState());
    }

    PurchasePlanOperateEnum(Integer state, String name) {
        this.state = state;
        this.name = name;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    /**
     * 针对字段类型为Integer
     * @return
     */
    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.state);
    }
    
    /**
     * 针对字段类型为String
     * @return
     */
    public String getCHName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
